Skip to content

[deprecation] Deprecate AddReturnArrayDocblockBasedOnArrayMapRector - #8342

Merged
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-return-array-docblock-based-on-array-map
Aug 10, 2026
Merged

[deprecation] Deprecate AddReturnArrayDocblockBasedOnArrayMapRector#8342
TomasVotruba merged 1 commit into
mainfrom
deprecate-add-return-array-docblock-based-on-array-map

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Deprecate AddReturnArrayDocblockBasedOnArrayMapRector, as too niche and of little practical value.

The rule only fires when array_map() gets an inline closure or arrow function with an explicit return type. In that case the item type is already written right there in the code, and static analysis infers it without any docblock:

 class SomeClass
 {
+    /**
+     * @return int[]
+     */
     public function getItems(array $items)
     {
         return array_map(function ($item): int {
             return $item->id;
         }, $items);
     }
 }

The realistic cases - a callable string, a first-class callable, a method reference, or a closure without a return type - are all skipped, so the rule adds a docblock only where it is least needed.

Changes:

  • rule implements DeprecatedInterface and throws on refactor()
  • removed from TypeDeclarationDocblocksLevel
  • tests and fixtures removed

@TomasVotruba
TomasVotruba force-pushed the deprecate-add-return-array-docblock-based-on-array-map branch from 5a5c0b5 to 91a947b Compare August 10, 2026 19:41
@TomasVotruba
TomasVotruba enabled auto-merge (squash) August 10, 2026 19:41
@TomasVotruba
TomasVotruba merged commit 8dcf980 into main Aug 10, 2026
54 checks passed
@TomasVotruba
TomasVotruba deleted the deprecate-add-return-array-docblock-based-on-array-map branch August 10, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant